package com.atguigu.pratice;

//创建多线程的方式2:实现runnable接口
public class RunnableDemo {
    public static void main(String[] args) {
//        System.out.println(Runtime.getRuntime().availableProcessors());
//        PrintDemoTest printDemoTest = new PrintDemoTest();
//        new Thread(printDemoTest).start();
        new Thread(() ->{
                for (int i = 0; i < 100; i++) {
                    if(i%2==0) System.out.println(Thread.currentThread().getName()+"\t"+i+"~~~");}
            }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    if(i%2!=0) System.out.println(Thread.currentThread().getName()+"\t"+i+"!!!");}
            }
            }
        ).start();
    }

}
//class PrintDemoTest implements Runnable{
//
//    //重写run方法
//    @Override
//    public void run() {
//        for (int i = 0; i < 100; i++) {
//            if(i%2==0){
//                System.out.println(Thread.currentThread().getName()+"\t"+i+"-------");
//
//            }
//        }
//    }
//}